/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Oswl_C
 */
@Entity
@Table(name = "nivel", catalog = "lecturadb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Nivel.findAll", query = "SELECT n FROM Nivel n"),
    @NamedQuery(name = "Nivel.findByNivCodigo", query = "SELECT n FROM Nivel n WHERE n.nivCodigo = :nivCodigo"),
    @NamedQuery(name = "Nivel.findByNivDescri", query = "SELECT n FROM Nivel n WHERE n.nivDescri = :nivDescri")})
public class Nivel implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "NIV_CODIGO")
    private Integer nivCodigo;
    @Column(name = "NIV_DESCRI")
    private String nivDescri;
    @OneToMany(mappedBy = "nivCodigo")
    private List<Ejercicio> ejercicios;

    public Nivel() {
    }

    public Nivel(Integer nivCodigo) {
        this.nivCodigo = nivCodigo;
    }

    public Integer getNivCodigo() {
        return nivCodigo;
    }

    public void setNivCodigo(Integer nivCodigo) {
        Integer oldNivCodigo = this.nivCodigo;
        this.nivCodigo = nivCodigo;
        changeSupport.firePropertyChange("nivCodigo", oldNivCodigo, nivCodigo);
    }

    public String getNivDescri() {
        return nivDescri;
    }

    public void setNivDescri(String nivDescri) {
        String oldNivDescri = this.nivDescri;
        this.nivDescri = nivDescri;
        changeSupport.firePropertyChange("nivDescri", oldNivDescri, nivDescri);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nivCodigo != null ? nivCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Nivel)) {
            return false;
        }
        Nivel other = (Nivel) object;
        if ((this.nivCodigo == null && other.nivCodigo != null) || (this.nivCodigo != null && !this.nivCodigo.equals(other.nivCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return nivDescri;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
